package com.itheima.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.itheima.dao.UserDao;

import com.itheima.domain.User;
import com.itheima.service.UserService;


import org.springframework.stereotype.Service;

import java.util.List;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserDao userDao;

    @Override
    public void save(User user) {
        boolean save = userDao.save(user);

}

    @Override
    public void update(User user) {
        boolean update = userDao.update(user);


    }

    @Override
    public void delete(Integer id) {
        boolean delete = userDao.delete(id);


    }

    @Override
    public User get(Integer id) {
        return userDao.get(id);
    }

    @Override
    public PageInfo<User> getAll(int page, int size) {
        PageHelper.startPage(page, size);
        List<User> all = userDao.getAll();
        return new PageInfo<User>(all);
    }

    @Override
    public User login(String userName, String password) {
        User user = userDao.getByUserNameAndPassword(userName, password);

        return user;
    }
}
